﻿<template>
    <div>
        <section class="jumb">
            <h3 class="jumb_header">Search github User</h3>
            <div>
                <input type="text" placeholder="" v-model="keyWord"/>&nbsp;
                <button @click="searchUser">Search</button>
            </div>
        </section>
    </div>
</template>

<script>
import axios from 'axios'//引入axios
export default {
    
    name: 'Search',
    components:{},
    data(){
        return{
            keyWord:'',
        }
    },
    methods:{
        searchUser(){
            axios.get(`https://api.github.com/search/users?q=${this.keyWord}`).then(
                response => {
                    console.log('请求成功了',response.data.items)
                    //console.log(this)//VueComponent
                    this.$bus.$emit('gotoUser',response.data.items)
                },
                error => {
                    console.log('请求失败了',error.message)
                }
            )
        }
    },
    mounted(){
        // console.log(this)//VueComponent
        
    },
    setup() {
        
    },
}
</script>


<style scoped>

</style>